﻿using System.Security.Cryptography;

namespace ConsoleApp1
{
    public class SmsService
    {
        // 生成6位验证码
        public string GenerateCode()
        {
            var rng = new byte[4];
            using (var generator = RandomNumberGenerator.Create())
            {
                generator.GetBytes(rng);
                return (BitConverter.ToUInt32(rng, 0) % 1000000).ToString("D6");
            }
        }
    }
}
